/**
 *  By Toma <my Util>
 *  2017-06-27 11:46:12
 */
;(function () {
  'use strict'

  var t = {}

  /**
   * 简单获取URI数据
   */
  t.urldata = function () {
    var shr = location.search
    var _d = {}
    var reg = /[?&][^?&]+=[^?&]+/g
    if (reg.test(shr)) {
      var a = shr.match(reg)
      for (var i in a) {
        var m = a[i].split('=')
        _d[m[0].substr(1)] = m[1]
      }
    } else {
      return
    }
    return _d
  }

  /**
   * 创建手机 tap 事件
   */
  t.tap = function () {
    function start (e) {
      e.target.tap_start = true
      e.target.tap_move = false
    }
    function move (e) {
      e.target.tap_move = true
      e.target.tap_start = false
    }
    function end (e) {
      if (!e.target.tap_move && e.target.tap_start) {
        var ev = document.createEvent('HTMLEvents')
        ev.initEvent('tap', true, false)
        e.target.dispatchEvent(ev)
      }
    }
    document.addEventListener('touchstart', start, false)
    document.addEventListener('touchmove', move, false)
    document.addEventListener('touchend', end, false)
  }

  window.t = t
})()
